package bakenote.xml;

import bakenote.ui.BakeNoteWindow;
import bakenote.core.Recipe;
import org.apache.pivot.collections.List;
import org.apache.pivot.io.IOTask;
import org.apache.pivot.util.concurrent.TaskExecutionException;

import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Created by IntelliJ IDEA.
 * User: lello
 * Date: 5/16/11
 * Time: 1:07 PM
 * To change this template use File | Settings | File Templates.
 */
public class ExportXMLTask extends IOTask<Void> {

    File xmlFile;
    List<Recipe> selectedRecipes;

    public ExportXMLTask(File xmlFile, List<Recipe> selectedRecipes) {
        this.xmlFile = xmlFile;
        this.selectedRecipes = selectedRecipes;
    }

    @Override
    public Void execute() throws TaskExecutionException {
        try {
            RecipeXMLWriter.writeXML(selectedRecipes, xmlFile);
        } catch (Exception ex) {
            Logger.getLogger(BakeNoteWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}
